<%--
  Created by IntelliJ IDEA.
  User: Administrator
  Date: 2019/10/24
  Time: 20:04
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<!DOCTYPE html>
<html>

<head>
    <meta charset="UTF-8">
    <title>欢迎页面-X-admin2.0</title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width,user-scalable=yes, minimum-scale=0.4, initial-scale=0.8,target-densitydpi=low-dpi" />
    <link rel="shortcut icon" href="/favicon.ico" type="image/x-icon" />
    <link rel="stylesheet" href="${pageContext.request.contextPath}/css/font.css">
    <link rel="stylesheet" href="${pageContext.request.contextPath}/css/xadmin.css">
    <script type="application/javascript" src="${pageContext.request.contextPath}/ztree/js/jquery-3.3.1.min.js"></script>
    <script type="text/javascript" src="${pageContext.request.contextPath}/lib/layui/layui.js" charset="utf-8"></script>
    <script type="text/javascript" src="${pageContext.request.contextPath}/js/xadmin.js"></script>
    <!-- 让IE8/9支持媒体查询，从而兼容栅格 -->
    <!--[if lt IE 9]>
    <script src="https://cdn.staticfile.org/html5shiv/r29/html5.min.js"></script>
    <script src="https://cdn.staticfile.org/respond.js/1.4.2/respond.min.js"></script>
    <![endif]-->
</head>

<body>
<div class="x-body">
    <form class="layui-form">
         <input type="hidden" name="aid" value="${adminpojo.aid}">
        <div class="layui-form-item">
            <label for="aname" class="layui-form-label">
                <span class="x-red">*</span>昵称
            </label>
            <div class="layui-input-inline">
                <input type="text" id="aname" name="aname" required="" lay-verify="required"
                       autocomplete="off" class="layui-input" value="${adminpojo.aname}">
            </div>
            <div class="layui-form-mid layui-word-aux">
                <span class="x-red">*</span>昵称
            </div>
        </div>

        <div class="layui-form-item">
            <label for="aphone" class="layui-form-label">
                <span class="x-red">*</span>手机
            </label>
            <div class="layui-input-inline">
                <input type="text" id="aphone" name="aphone" required="" lay-verify="phone"
                       autocomplete="off" class="layui-input" value="${adminpojo.aphone}">
            </div>
            <div class="layui-form-mid layui-word-aux">
                <span class="x-red">*</span>将会成为您唯一的登入名
            </div>
        </div>
        <div class="layui-form-item">
            <label for="aemail" class="layui-form-label">
                <span class="x-red">*</span>邮箱
            </label>
            <div class="layui-input-inline">
                <input type="text" id="aemail" name="aemail" required="" lay-verify="email"
                       autocomplete="off" class="layui-input" value="${adminpojo.aemail}">
            </div>
            <div class="layui-form-mid layui-word-aux">
                <span class="x-red">*</span>
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label"><span class="x-red">*</span>角色</label>
            <div class="layui-input-block">
                <c:forEach items="${rolelist}" var="role">
                    <input type="checkbox" name="roles" value="${role.rid}" lay-skin="primary" title="${role.rname}"
                        <c:forEach items="${adminpojo.rolePojoList}" var="re">
                            <c:if test="${re.rid eq role.rid}">
                            checked
                    </c:if>
                    </c:forEach>
                    >
                </c:forEach>

            </div>
        </div>
        <div class="layui-form-item">
            <label for="L_pass" class="layui-form-label">
                <span class="x-red">*</span>密码
            </label>
            <div class="layui-input-inline">
                <input type="password" id="L_pass" name="apass" required="" lay-verify="pass"
                       autocomplete="off" class="layui-input" value="${adminpojo.apass}" id="apass01">
            </div>
            <div class="layui-form-mid layui-word-aux">
                6到16个字符
            </div>
        </div>
        <div class="layui-form-item">
            <label for="L_repass" class="layui-form-label">
                <span class="x-red">*</span>确认密码
            </label>
            <div class="layui-input-inline">
                <input type="password" id="L_repass" required="" lay-verify="repass"
                       autocomplete="off" class="layui-input" id="apass02" name="prapass">
            </div>
        </div>
        <div class="layui-form-item">
            <label for="L_repass" class="layui-form-label">
            </label>
            <button  class="layui-btn" lay-filter="add" lay-submit="" type="button" id="btn03">
                保存修改
            </button>
        </div>
    </form>
</div>
<script>
$("#btn03").click(function () {
    var data = $("form").serializeArray();
    var apass01=data.apass;
    var apass02=data.prapass;
    // console.info(data);
    $.ajax({
        type:"post",
        url:"${pageContext.request.contextPath}/editAdmin.do",
        data:data,
        beforeSend:function () {
            console.info(apass02,apass01);
            if (apass01!=apass02){
                layer.msg("两次密码不一致！",{time:1000,icon:6,shift:5});
                return false;
            }else{
                return true;
            }
        },
        success:function (result) {
            if (result.flag){
                layer.msg("修改成功！",{time: 1000,icon: 6,shift: 6});
            }else{
                layer.msg("修改失败！",{time:1000,icon:6,shift:5});
            }
            // 获得frame索引
            var index = parent.layer.getFrameIndex(window.name);
            //关闭当前frame
            parent.layer.close(index);
        }
    })
})
</script>
</body>

</html>